package meituanone;

import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/8/30 21:38
 * 小美的外卖订单
 */
public class Main01 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt(); // 菜品的总数
            double[] a = new double[n]; // 每个菜的原价
            double[] b = new double[n]; // 每个菜的折扣价
            double aTotal = 0, bTotal = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextDouble();
                b[i] = in.nextDouble();
                aTotal += a[i];
                bTotal += b[i];
            }
            double x = in.nextDouble(); // 满
            double y = in.nextDouble(); // 减
            // 检查数据是否有误
            boolean flag = check(a, b, x, y);
            if (!flag) {
                // 输入数据有误
                System.out.println("error");
            } else {
                // 计算最优惠的价格
                double cheaperPrice = aTotal; // 先记录原价总和
                if (cheaperPrice >= x) {
                    // 触发满减规则
                    cheaperPrice = cheaperPrice - y;
                }
                cheaperPrice = Math.min(cheaperPrice, bTotal); // 与折扣价进行比较
                System.out.printf("%.2f%n", cheaperPrice);
            }
        }
        in.close();
    }

    // 检查输入的数据是否有误, 如果输入的数据有误则返回 false
    private static boolean check(double[] a, double[] b, double x, double y) {
        boolean ret = true;
        // 检查折扣价是否高于原价
        // 检查价格是否为负数
        int n = a.length;
        for (int i = 0; i < n; i++) {
            if (b[i] > a[i] || b[i] <= 0 || a[i] <= 0) {
                ret = false;
            }
        }
        // 检查满减是否高于总价
        if (x < y || x <= 0 || y <= 0) {
            ret = false;
        }
        return ret;
    }
}
